package com.hello.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hello.common.log.annotation.Log;
import com.hello.common.log.enums.BusinessType;
import com.hello.common.security.annotation.RequiresPermissions;
import com.hello.system.domain.CommentReplies;
import com.hello.system.service.ICommentRepliesService;
import com.hello.common.core.web.controller.BaseController;
import com.hello.common.core.web.domain.AjaxResult;
import com.hello.common.core.utils.poi.ExcelUtil;
import com.hello.common.core.web.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 评论回复Controller
 * 
 * @author hello
 * @date 2025-10-29
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/commentReplies")
public class CommentRepliesController extends BaseController
{
    private final ICommentRepliesService commentRepliesService;

    /**
     * 查询评论回复列表
     */
    @RequiresPermissions("system:commentReplies:list")
    @GetMapping("/list")
    public TableDataInfo list(CommentReplies commentReplies)
    {
        startPage();
        List<CommentReplies> list = commentRepliesService.selectCommentRepliesList(commentReplies);
        return getDataTable(list);
    }

    /**
     * 导出评论回复列表
     */
    @RequiresPermissions("system:commentReplies:export")
    @Log(title = "评论回复", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CommentReplies commentReplies)
    {
        List<CommentReplies> list = commentRepliesService.selectCommentRepliesList(commentReplies);
        ExcelUtil<CommentReplies> util = new ExcelUtil<CommentReplies>(CommentReplies.class);
        util.exportExcel(response, list, "评论回复数据");
    }

    /**
     * 获取评论回复详细信息
     */
    @RequiresPermissions("system:commentReplies:query")
    @GetMapping(value = "/{replyId}")
    public AjaxResult getInfo(@PathVariable("replyId") Long replyId)
    {
        return success(commentRepliesService.selectCommentRepliesByReplyId(replyId));
    }

    /**
     * 新增评论回复
     */
    @RequiresPermissions("system:commentReplies:add")
    @Log(title = "评论回复", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CommentReplies commentReplies)
    {
        return toAjax(commentRepliesService.insertCommentReplies(commentReplies));
    }

    /**
     * 修改评论回复
     */
    @RequiresPermissions("system:commentReplies:edit")
    @Log(title = "评论回复", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CommentReplies commentReplies)
    {
        return toAjax(commentRepliesService.updateCommentReplies(commentReplies));
    }

    /**
     * 删除评论回复
     */
    @RequiresPermissions("system:commentReplies:remove")
    @Log(title = "评论回复", businessType = BusinessType.DELETE)
	@DeleteMapping("/{replyIds}")
    public AjaxResult remove(@PathVariable Long[] replyIds)
    {
        return toAjax(commentRepliesService.deleteCommentRepliesByReplyIds(replyIds));
    }
}
